#include "person.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <random>
#include <deque>
#include <map>
#include <list>
#include <numeric>

using namespace std;

int main(int argc, char **argv)
{
    deque<Person *> listPlayer; 
    multimap<int, Person *> mapPlayer;
    multimap<int, Person *> mapPlayer1;
    int i = 0;
    
   

    /* 设置随机数种子 */
    srand(time(NULL));

    /* 初始化选手名字 */
    initPalyerName(listPlayer);
#ifdef DEBUG
    cout << "---------------------------------" << endl;
    /* 显示选手信息 */
    showPlayer(listPlayer);
#endif

    /* 选手洗牌 号码赋值 */
    shufflePlayer(listPlayer);

#ifdef DEBUG
    cout << "---------------------------------" << endl;

    /* 显示选手信息 */
    showPlayer(listPlayer);
#endif

    /* 选手随机分组 */
    setGroup(mapPlayer, listPlayer, 4);
    

#ifdef DEBUG
    cout << "---------------------------------" << endl;
    /* 显示分组信息 */
    showMapPlayer(mapPlayer);
#endif
    
    /* 打分 */
    markPlayer(mapPlayer);

#ifdef DEBUG
    cout << "---------------------------------" << endl;
    /* 显示分组信息 */
    showMapPlayer(mapPlayer);
#endif
#ifdef DEBUG
    cout << "---------------------------------" << endl;
    /* 显示选手信息 */
    showPlayer(listPlayer);
#endif
    
    /* 第一次淘汰 */
    weedOut(mapPlayer, listPlayer, 4);

    cout << "第一轮" << endl;

    
#ifdef DEBUG
    cout << "---------------------------------" << endl;
    /* 显示分组信息 */
    showMapPlayer(mapPlayer);
#endif

#ifdef DEBUG
    cout << "---------------------------------" << endl;
    /* 显示选手信息 */
    showPlayer(listPlayer);
#endif
    
    
    mapPlayer.clear();

    /* 选手随机分组 */
    setGroup(mapPlayer, listPlayer, 2);

    /* 打分 */
    markPlayer(mapPlayer);

    /* 第二次淘汰 */
    weedOut(mapPlayer, listPlayer, 2);

    cout << "第二轮" << endl;
    
    
#ifdef DEBUG
    cout << "---------------------------------" << endl;
    /* 显示分组信息 */
    showMapPlayer(mapPlayer);
#endif

#ifdef DEBUG
    cout << "---------------------------------" << endl;
    /* 显示选手信息 */
    showPlayer(listPlayer);
#endif

    mapPlayer.clear();

    /* 选手随机分组 */
    setGroup(mapPlayer, listPlayer, 1);

    /* 打分 */
    markPlayer(mapPlayer);

    /* 第三次淘汰 */
    weedOut(mapPlayer, listPlayer, 1);

    cout << "第三轮" << endl;

#ifdef DEBUG
    cout << "---------------------------------" << endl;
    /* 显示分组信息 */
    showMapPlayer(mapPlayer);
#endif

#ifdef DEBUG
    cout << "---------------------------------" << endl;
    /* 显示选手信息 */
    showPlayer(listPlayer);
#endif


    return 0;
}